Repository navigation
fix(session): reject an access token that has no exp claim - #789
Open
gjtorikian wants to merge 1 commit into
Open
gjtorikian wants to merge 1 commit into
gjtorikian wants to merge 1 commit into
Conversation
The session verifier accepted an access token with a correct signature and no exp claim. It also accepted an exp claim that was a string of digits. Now Session and AsyncSession give INVALID_JWT for these tokens. Each jwt.decode call now has "require": ["exp"] in its options, and a type check rejects an exp claim that is not a number. The result for a numeric exp, the signature rules and the public API do not change.
Contributor
Confidence Score: 5/5
[Medium impact] The PR appears safe to merge; no actionable issues were found. SummaryRequires a numeric
Reviews (1) · Last reviewed commit: "fix(session): reject an access token tha..." · Reviewed by Greptile |
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On
main, the session verifier accepted an access token that had a correct signature and noexpclaim. It also accepted anexpclaim that was a string of digits, because PyJWT readsexpwithint(). NowauthenticateandrefreshofSessionandAsyncSessionreturn an error response with theINVALID_JWTreason for these tokens. That is the result for a token with an incorrect signature. Eachjwt.decodecall of the verifier now has"require": ["exp"]in its options. A check after the call rejects anexpclaim that is not a JSON number.Behavior changes
mainexpclaimauthenticateandrefreshreturn a success responseINVALID_JWTexpis a string thatint()can read, for example"1900000000"authenticateandrefreshreturn a success response until that time (plusjwt_leeway)INVALID_JWTexpistrueorfalse, andjwt_leewayis larger than the current Unix timeauthenticateandrefreshreturn a success responseINVALID_JWTexpas JSONnullgaveINVALID_JWTonmain. It givesINVALID_JWTnow.SessionandAsyncSession, and for RS256 and ES256.refreshrejects the new access token, it keepssession_data.get_logout_urlraises its usualValueErrorfor a token thatauthenticaterejects.No change
expkeeps its result. A token that is not expired authenticates as before, with an integerexpor anexpwith a fraction. An expired token givesINVALID_JWTas before, andrefreshkeepssession_data.Tests
authenticateandrefreshofSessionandAsyncSession.exp, withexpasnull, or withexpas a string of digits givesINVALID_JWT, andrefreshkeepssession_data.requireoption rejects a token with noexpclaim.expor anexpwith a fraction still authenticates and refreshes.expand an arrayexp.mainhad a token with noexpclaim and an expected success. Thus no fixture got anexpclaim.Documentation
Does this require changes to the WorkOS Docs? E.g. the API Reference or code snippets need updates.
If yes, link a related docs PR and add a docs maintainer as a reviewer. Their approval is required.